package com.example.widget.view

import com.example.base.BaseActivity
import com.example.base.ui.CommonButtonColors
import com.example.base.commonView.CommonText
import com.example.base.commonView.CommonTheme
import com.example.base.commonView.TitleBar
import android.os.Bundle
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.ContextAmbient
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.unit.dp

class ButtonShowActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            showView()
        }
    }

    @Composable
    fun showView() {
        //获取上下文
        val context = ContextAmbient.current as BaseActivity
        CommonTheme {
            Column(modifier = Modifier.fillMaxSize()) {
                TitleBar(title = "Button") {
                    context.finish()
                }
                //普通的按钮
                Button(
                    onClick = {},
                    modifier = Modifier.padding(10.dp),
                    colors = CommonButtonColors()
                ) {
                    CommonText(text = "Button", color = Color.White)
                }

                //还不完善，边框无法完全覆盖
                Button(
                    onClick = {},
                    modifier = Modifier.padding(10.dp),
                    border = BorderStroke(
                        5.dp,
                        Color.LightGray
                    )
                ) {
                    CommonText(text = "Button with border", color = Color.White)
                }

                //圆角按钮
                Button(
                    onClick = {},
                    modifier = Modifier.padding(10.dp),
                    shape = RoundedCornerShape(10.dp)
                ) {
                    CommonText(text = "Button with shape", color = Color.White)
                }

                //OutlinedButton
                OutlinedButton(onClick = {}, modifier = Modifier.padding(10.dp)) {
                    CommonText(text = "OutlinedButton", color = Color.DarkGray)
                }

                //TextButton
                TextButton(onClick = {}, modifier = Modifier.padding(10.dp)) {
                    CommonText(text = "TextButton", color = Color.DarkGray)
                }
            }
        }
    }
}